package com.jnshu.quartz;

import com.jnshu.service.MessageService;
import com.jnshu.tools.resultUtils.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

/**
 * @author xmp
 * @date 2019/8/12 19:46
 */
@Slf4j
@Component
public class Mybean implements Job {

   public static MessageService messageService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        Long id = jobDataMap.getLong("id");
        log.info("触发的id:"+id);
        Integer status = jobDataMap.getInt("status");
        log.info("准备改变的状态:"+status);
//        MessageListDetailDto messageListDetailDto = messageService.selectMessageById(id);
//        log.info("需要触发的ID："+id);
//        log.info("ID的信息："+messageListDetailDto);
        ResultBean update = messageService.updateMessageStatus(id,status);
        log.info("触发器更新的结果："+update);
    }
}
